/**
 * Copyright © 1998-2020, Glodon Inc. All Rights Reserved.
 */
package reactor2;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * 此处填写类简介
 * <p>
 * 此处填写类说明
 * </p>
 * 
 * @author glodon
 * @since jdk1.6 2020年8月3日
 */

public class EventDispatcher {
	//维护关系
	private  Map<EventType, IEventHandler> eventHandlerMap = new ConcurrentHashMap<EventType, IEventHandler>();

	/***
	 * 
	 * TODO
	 * @param key
	 * @param handler
	 */
	public void registerHandler(EventType key, IEventHandler handler) {
		eventHandlerMap.put(key, handler);
	}

	/****
	 * 
	 * TODO
	 * @param key
	 * @return
	 */
	public IEventHandler getEventHandler(EventType key) {
		if (key == null)
			throw new NullPointerException();
		IEventHandler handler = eventHandlerMap.get(key);
		if (handler == null)
			throw new NullPointerException();
		return handler;
	}

	public Map<EventType, IEventHandler> getEventHandlerMap() {
		return eventHandlerMap;
	}

	public void setEventHandlerMap(Map<EventType, IEventHandler> eventHandlerMap) {
		this.eventHandlerMap = eventHandlerMap;
	};
	
}
